<tbody>
    <tr>
        <?php for ($index = 0; $index < count($this->days); $index++): ?>
        <td><strong>Hora</strong></td>
            <td><strong><?= $this->days[$index]['label'] ?></strong</td>
            
        <?php endfor;;?>
    </tr>
    <?php  foreach($this->horarios as $horario): ?>
        <tr class="<?=$horario?> linhaHora">
            <?php for ($index = 0; $index < count($this->days); $index++): ?>
                <td class="hora"><strong><?=$horario['hora']?></strong></td>
                <td class="<?=$this->days[$index]['label']?>  dia">
                   <table class="funcionario table-striped linhaHora">
                        <?php  
                            $atendFun= null;
                            foreach($this->atendimentos as $atend){
                                if($atend['data_atend']== $this->days[$index]['dia'] && $atend['hora'] == $horario['hora']){
                                    $atendFun[]=$atend;
                                }
                            }

                            $qnt = 3;
                            $replace= '';
                            foreach ($this->maxFunc as $maxFun){
                                if($horario['hora'] == $maxFun['hora']){
                                    $qnt = $maxFun['qnt'];
                                    break;
                                }
                            }
                            for($i = 1; $i < $qnt ; $i++){
                                $atdMaxDia = 3;
                                foreach ($this->maxAtend as $maxAt){
                                    if($this->days[$index]['dia'] == $maxAt['dia']){
                                        $atdMaxDia = $maxAt['quantidade'];
                                        break;
                                    }
                                }
                                
                                $replace.='<tr><td class="nomeFunc">#func'.$i.'</td>';
                                           
                                    for($j = 1; $j < $atdMaxDia+1; $j++){
                                        $replace.='<td class="status">#atedn'.$i.$j.'</td>';
                                    }
                                
                                
                                $replace.='</tr>';
                            }
                            
                            echo $this->atend()->replaceAtend($atendFun,$replace);
                            
                         ?>
                    </table>
                </td>
           <?php endfor;?>
        </tr>
    <?php endforeach;?>
</tbody>